package com.example.mybatisdemo.config;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class DynamicDataSourceHolder {

    private static ThreadLocal<String> finalDbType = new ThreadLocal();
    private static ThreadLocal<String> manualDbType = new ThreadLocal();


    public static final String master = "master";
    public static final String linkage = "linkage";
    public static final String gov = "gov";
    public static final String sugetong = "sugetong";


    public static String get(){
        String db = finalDbType.get();
        if(db == null){
            db = master;
        }
        return db;
    }

    public static void setDBType(String type){
        finalDbType.set(type);
    }
    public static void clear(){
        finalDbType.remove();
    }

    public static void setManualDBType(String type){
        manualDbType.set(type);
    }
    public static String getManualDBType(){
        return manualDbType.get();
    }

    public static void manualDBTypeClear(){
        manualDbType.remove();
    }



}
